package cn.zxy.controller;

import cn.zxy.model.RegisterInfo;
import cn.zxy.model.User;
import cn.zxy.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/user")
public class UserController {
    @Autowired
    private UserService userService;

    @PostMapping("/register")
    //因为前端传的是字符串，所以要用RequestBody来接收
    public Integer register(@RequestBody RegisterInfo registerInfo){
        return userService.register(registerInfo);
    }

    //登录
    @PostMapping("/login")
    public User login(@RequestBody RegisterInfo registerInfo){
        return userService.login(registerInfo);
    }
}
